<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>JSON-RPC</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/JSON-RPC"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-JSON-RPC rootpage-JSON-RPC skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">JSON-RPC</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p><b>JSON-RPC</b> (<b>JavaScript Object Notation-Remote Procedure Call</b>) is a <a href="JSON" title="JSON">JSON</a>-based <a href="Wire_protocol" title="Wire protocol">wire protocol</a> for <a href="Remote_procedure_call" title="Remote procedure call">remote procedure calls</a> (RPC). It is similar to the <a href="XML-RPC" title="XML-RPC">XML-RPC</a> protocol, defining only a few data types and commands. JSON-RPC allows for notifications (data sent to the server that does not require a response) and for multiple calls to be sent to the server which may be answered asynchronously.
</p><p>The JSON-RPC protocol is transport-independent and can be carried over many different data transport protocols, including <a href="File_descriptor" title="File descriptor">file descriptor</a> I/O, <a href="HTTP" title="HTTP">HTTP</a> and <a href="TCP" class="mw-disambig" title="TCP">TCP</a>. It does not directly provide any support for authentication or authorization.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<table class="wikitable">
<tbody><tr>
<th>Version
</th>
<th>Description
</th>
<th>Dated
</th></tr>
<tr>
<td>1.0
</td>
<td><a rel="nofollow" class="external text" href="https://www.jsonrpc.org/specification_v1">Original version</a>
</td>
<td>2005
</td></tr>
<tr>
<td>1.1 WD
</td>
<td><a rel="nofollow" class="external text" href="https://jsonrpc.org/historical/json-rpc-1-1-wd.html">Working draft</a>. Adds named parameters, adds specific error codes, and adds introspection functions.
</td>
<td>2006-08-07
</td></tr>
<tr>
<td>1.1 Alt
</td>
<td><a rel="nofollow" class="external text" href="http://jsonrpc.org/historical/json-rpc-1-1-alt.txt">Suggestion for a simple JSON-RPC 1.1</a>. Alternative proposal to 1.1 WD.
</td>
<td>2007-05-06
</td></tr>
<tr>
<td>1.1 Object Specification
</td>
<td><a rel="nofollow" class="external text" href="http://jsonrpc.org/historical/json-rpc-object-specification.html">Object Specification</a>. Alternative proposal to 1.1 WD/1.1ALT.
</td>
<td>2007-07-30
</td></tr>
<tr>
<td>1.2
</td>
<td><a rel="nofollow" class="external text" href="http://jsonrpc.org/historical/jsonrpc12_proposal.html">Proposal</a>. A later revision of this document was renamed to 2.0.
</td>
<td>2007-12-27
</td></tr>
<tr>
<td>2.0
</td>
<td><a rel="nofollow" class="external text" href="http://jsonrpc.org/historical/json-rpc-1-2-proposal.txt">Specification proposal</a>
</td>
<td>2009-05-24
</td></tr>
<tr>
<td>2.0 (Revised-)
</td>
<td><a rel="nofollow" class="external text" href="http://jsonrpc.org/spec">Specification</a>
</td>
<td>2010-03-26
</td></tr></tbody></table>
<div class="mw-heading mw-heading2"><h2 id="Usage">Usage</h2></div>
<p>JSON-RPC works by sending a request to a server implementing this protocol. The client in that case is typically software intending to call a single method of a remote system. Multiple input parameters can be passed to the remote method as an array or object, whereas the method itself can return multiple output data as well. (This depends on the implemented version.)
</p><p>All transfer types are single objects, serialized using JSON.<sup id="cite_ref-json-rpc1_1-0" class="reference"><a href="#cite_note-json-rpc1-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> A request is a call to a specific method provided by a remote system. It can contain three members:
</p>
<ul><li><code>method</code> - A string with the name of the method to be invoked. Method names that begin with "rpc." are reserved for rpc-internal methods.</li>
<li><code>params</code> - An object or array of values to be passed as parameters to the defined method. This member may be omitted.</li>
<li><code>id</code> - A string or non-fractional number used to match the response with the request that it is replying to.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> This member may be omitted if no response should be returned.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup></li></ul>
<p>The receiver of the request must reply with a valid response to all received requests. A response can contain the members mentioned below.
</p>
<ul><li><code>result</code> - The data returned by the invoked method. If an error occurred while invoking the method, this member must not exist.<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup></li>
<li><code>error</code> - An error object if there was an error invoking the method, otherwise this member must not exist.<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> The object must contain members <i>code</i> (integer) and <i>message</i> (string).<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> An optional <i>data</i> member can contain further server-specific data. There are pre-defined error codes which follow those defined for XML-RPC.</li></ul>
<ul><li><code>id</code> - The id of the request it is responding to.</li></ul>
<p>Since there are situations where no response is needed or even desired, notifications were introduced. A notification is similar to a request except for the id, which is not needed because no response will be returned. In this case the <code>id</code> property should be omitted (Version 2.0) or be <code>null</code> (Version 1.0).
</p>
<div class="mw-heading mw-heading2"><h2 id="Examples">Examples</h2></div>
<p>In these examples, <code>--></code> denotes data sent to a service (<i>request</i>), while <code><--</code> denotes data coming from a service. Although <code><--</code> is often called a <i>response</i> in client–server computing, depending on the JSON-RPC version it does not necessarily imply an <i>answer</i> to a request<i>.</i>
</p>
<div class="mw-heading mw-heading3"><h3 id="Version_2.0">Version 2.0</h3></div>
<p>Request and response:
</p>
<div class="mw-highlight mw-highlight-lang-json mw-content-ltr" dir="ltr"><pre><span class="mi">--</span><span class="err">></span><span class="w"> </span><span class="p">{</span><span class="nt">"jsonrpc"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2.0"</span><span class="p">,</span><span class="w"> </span><span class="nt">"method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"subtract"</span><span class="p">,</span><span class="w"> </span><span class="nt">"params"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="nt">"minuend"</span><span class="p">:</span><span class="w"> </span><span class="mi">42</span><span class="p">,</span><span class="w"> </span><span class="nt">"subtrahend"</span><span class="p">:</span><span class="w"> </span><span class="mi">23</span><span class="p">},</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">3</span><span class="p">}</span>
<span class="err"><</span><span class="mi">--</span><span class="w"> </span><span class="p">{</span><span class="nt">"jsonrpc"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2.0"</span><span class="p">,</span><span class="w"> </span><span class="nt">"result"</span><span class="p">:</span><span class="w"> </span><span class="mi">19</span><span class="p">,</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">3</span><span class="p">}</span>
</pre></div>
<p>Notification (no response):
</p>
<div class="mw-highlight mw-highlight-lang-json mw-content-ltr" dir="ltr"><pre><span class="mi">--</span><span class="err">></span><span class="w"> </span><span class="p">{</span><span class="nt">"jsonrpc"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2.0"</span><span class="p">,</span><span class="w"> </span><span class="nt">"method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"update"</span><span class="p">,</span><span class="w"> </span><span class="nt">"params"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">]}</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Version_1.1_(Working_Draft)">Version 1.1 (Working Draft)</h3></div>
<p>Request and response:
</p>
<div class="mw-highlight mw-highlight-lang-json mw-content-ltr" dir="ltr"><pre><span class="mi">--</span><span class="err">></span><span class="w"> </span><span class="p">{</span><span class="nt">"version"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1.1"</span><span class="p">,</span><span class="w"> </span><span class="nt">"method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"confirmFruitPurchase"</span><span class="p">,</span><span class="w"> </span><span class="nt">"params"</span><span class="p">:</span><span class="w"> </span><span class="p">[[</span><span class="s2">"apple"</span><span class="p">,</span><span class="w"> </span><span class="s2">"orange"</span><span class="p">,</span><span class="w"> </span><span class="s2">"mangoes"</span><span class="p">],</span><span class="w"> </span><span class="mf">1.123</span><span class="p">],</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"194521489"</span><span class="p">}</span>
<span class="err"><</span><span class="mi">--</span><span class="w"> </span><span class="p">{</span><span class="nt">"version"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1.1"</span><span class="p">,</span><span class="w"> </span><span class="nt">"result"</span><span class="p">:</span><span class="w"> </span><span class="s2">"done"</span><span class="p">,</span><span class="w"> </span><span class="nt">"error"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"194521489"</span><span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Version_1.0">Version 1.0</h3></div>
<p>Request and response:
</p>
<div class="mw-highlight mw-highlight-lang-json mw-content-ltr" dir="ltr"><pre><span class="mi">--</span><span class="err">></span><span class="w"> </span><span class="p">{</span><span class="nt">"method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"echo"</span><span class="p">,</span><span class="w"> </span><span class="nt">"params"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Hello JSON-RPC"</span><span class="p">],</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">}</span>
<span class="err"><</span><span class="mi">--</span><span class="w"> </span><span class="p">{</span><span class="nt">"result"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Hello JSON-RPC"</span><span class="p">,</span><span class="w"> </span><span class="nt">"error"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="GRPC" title="GRPC">gRPC</a> - cross-platform binary RPC protocol</li>
<li><a href="SOAP" title="SOAP">SOAP</a> - a messaging protocol</li>
<li><a href="JSON-WSP" title="JSON-WSP">JSON-WSP</a> - a JSON-RPC inspired protocol with a service description specification</li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<ol class="references">
<li id="cite_note-json-rpc1-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-json-rpc1_1-0">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20080517011921/http://json-rpc.org/wiki/specification">"specification - JSON-RPC - Trac"</a>. Archived from <a rel="nofollow" class="external text" href="http://json-rpc.org/wiki/specification">the original</a> on 2008-05-17<span class="reference-accessdate">. Retrieved <span class="nowrap">2008-05-14</span></span>.</cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.jsonrpc.org/specification">"JSON-RPC 2.0 Specification"</a>. <q>id: An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null and Numbers SHOULD NOT contain fractional parts</q></cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.jsonrpc.org/specification">"JSON-RPC 2.0 Specification"</a>. <q>A Notification is a Request object without an "id" member. A Request object that is a Notification signifies the Client's lack of interest in the corresponding Response object, and as such no Response object needs to be returned to the client. The Server MUST NOT reply to a Notification, including those that are within a batch request. Notifications are not confirmable by definition, since they do not have a Response object to be returned. As such, the Client would not be aware of any errors (like e.g. "Invalid params", "Internal error").</q></cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.jsonrpc.org/specification">"JSON-RPC 2.0 Specification"</a>. <q>result: This member is REQUIRED on success. This member MUST NOT exist if there was an error invoking the method. The value of this member is determined by the method invoked on the Server.</q></cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.jsonrpc.org/specification">"JSON-RPC 2.0 Specification"</a>. <q>error: This member is REQUIRED on error. This member MUST NOT exist if there was no error triggered during invocation. The value for this member MUST be an Object as defined in section 5.1.</q></cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.jsonrpc.org/specification">"JSON-RPC 2.0 Specification"</a>. <q>Error object: When a rpc call encounters an error, the Response Object MUST contain the error member with a value that is a Object with the following members: (code) - A Number that indicates the error type that occurred. This MUST be an integer. (message) - A String providing a short description of the error. The message SHOULD be limited to a concise single sentence. (data) - A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).</q></cite></span>
</li>
</ol>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><span class="official-website"><span class="url"><a rel="nofollow" class="external text" href="https://www.jsonrpc.org/">Official website</a></span></span> </li>
<li><a rel="nofollow" class="external text" href="https://groups.google.com/group/json-rpc">JSON-RPC Google Group</a> discussing topics of and around the protocol</li>
<li><a rel="nofollow" class="external text" href="http://www.simple-is-better.org/json-rpc/">JSON-RPC specifications, MNlinks etc.</a></li>
<li><a rel="nofollow" class="external text" href="http://www.simple-is-better.org/json-rpc/transport_http.html">HTTP transport</a> description for JSON-RPC-2</li>
<li><a rel="nofollow" class="external text" href="https://open-rpc.org">OpenRPC Specification</a> Service description format for JSON-RPC. (open-api, but for json rpc)</li>
<li><a rel="nofollow" class="external text" href="https://github.com/omniti-labs/jsend">JSend</a> - a similar specification which defines only format of response</li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-06-05" href="https://en.wikipedia.org/wiki/?title=JSON-RPC&oldid=1294068170">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>